// pages/collect/collect.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabList:[
      {
        id:0,
        name:"商品收藏",
        isActive:true
      },
      {
        id:1,
        name:"品牌收藏",
        isActive:false
      },
      {
        id:3,
        name:"店铺收藏",
        isActive:false
      },
      {
        id:4,
        name:"浏览足迹",
        isActive:false
      },
    ],
    btnList:[
      {
        id:0,
        name:"全部",
        isActive:true
      },
      {
        id:1,
        name:"正在热卖",
        isActive:false
      },
      {
        id:2,
        name:"即将上线",
        isActive:false
      }
    ],
    collect:[]
  },


  
  tabsChange:function(e){
    console.log(e);
    let {activeId} = e.detail;
    let {tabList} = this.data;
    tabList.map(item=>item.isActive=item.id===activeId);
    this.setData({
      tabList
    })

  },

  itemClick:function(e){
    console.log(e);
    let {activeId} = e.currentTarget.dataset;
    this.data.btnList.map(item=>item.isActive=item.id===activeId)
    this.setData({
      btnList:this.data.btnList
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const collect = wx.getStorageSync('collect')||[];
    this.setData({
      collect
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})